package com.framework.buss.ai.controller;

import com.framework.buss.ai.model.KnowledgeFile;
import com.framework.buss.ai.params.KnowledgeFileParam;
import com.framework.buss.ai.service.IKnowledgeFileService;
import com.framework.common.domain.ResultData;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author zhangzhg
 */
@RestController
@RequestMapping("/knowledge-file")
@Api(value = "knowledge-file", tags = "知识库文件")
public class KnowledgeFileController {
    @Autowired
    private IKnowledgeFileService knowledgeFileService;

    @ApiOperation("获取列表接口")
    @GetMapping("list")
    public ResultData list(KnowledgeFileParam param) {
        List<KnowledgeFile> list = knowledgeFileService.list(param);
        return ResultData.data(list);
    }

    @ApiOperation("获取单个")
    @GetMapping("one/{id}")
    public ResultData getOne(@PathVariable("id") String id) {
        KnowledgeFile item = knowledgeFileService.getOne(id);
        return ResultData.data(item);
    }

    @ApiOperation(value = "保存")
    @PostMapping(value = "/save")
    public ResultData save(@RequestBody KnowledgeFile param) {
        String id = knowledgeFileService.save(param);
        return ResultData.success(id);
    }

    @ApiOperation(value = "删除")
    @PostMapping(value = "/del")
    public ResultData del(@RequestBody List<String> ids) {
        knowledgeFileService.del(ids);
        return ResultData.success();
    }
}
